package br.spring.main;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.util.Assert;

import br.spring.aspect.annotation.MindReader;
import br.spring.aspect.annotation.Thinker;
import br.spring.performers.PerformanceException;
import br.spring.performers.Performer;

public class TestPerformer {

	public static void main(String[] args) {
		ApplicationContext ctx = new ClassPathXmlApplicationContext(
				"configspring.xml");

		// Performer performer = (Performer) ctx.getBean("duke");
		try {
			// performer.perform();
			/*
			 * Performer p = (Performer) ctx.getBean("kenny"); p.perform();
			 * Performer p2 = (Performer) ctx.getBean("kenny2"); p2.perform();
			 */
			Performer p3 = (Performer) ctx.getBean("instrumentalist");
			p3.perform();

		} catch (PerformanceException e) {
			e.printStackTrace();
		}

		Thinker thinker = (Thinker) ctx.getBean("volunteer");
		MindReader reader = (MindReader) ctx.getBean("magician");

		String thought = "I'm thinking about spring!";

		thinker.thinkOfSomething(thought);
		Assert.isTrue(thought.equals(reader.getThoughts()));

	}

}
